#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2021/11/8 12:58 上午
# @Author  : WangZhixing


#将作者的dependend依赖转换为csv的数据
def deprsf2csv(f1,f2):
    with open(f1, 'r',encoding="utf-8") as fa:
        with open(f2, 'w') as fb:
            data = fa.read().split('\n')[:-1]
            for line in data:
                x = line.split()
                if x[0] == "depends":
                    fb.write(x[1]+" "+x[2]+' 1\n')
                else:
                    fb.write(x[0] + " " + x[1] + ' 1\n')

def labelrsf2csv(f1,f2):
    with open(f1, 'r') as fa:
        with open(f2, 'w') as fb:
            data = fa.read().split('\n')[:-1]
            for line in data:
                x = line.split()
                fb.write(x[1]+" "+x[2]+'\n')


if __name__ == '__main__':

    path=[]
    deprsf2csv("D:\module-reverse-by-gnn\mdgdata\\raw\edge.rsf",
            "D:\module-reverse-by-gnn\mdgdata\\raw\edge.csv")
